
Topic Name
Introduction to C#
Environment Setup
C# Keywords
Contextual Keywords
C# Namespaces
What Is Class?
What is Object?
Data Types
Nullable Types
C# Variables
What are Access Modifiers?
What is Property?
What is Indexer?
Hello world Program
What is Type conversion?
What is if else condition?
What is Array?
What is Jagged Array?
What is ArrayList?
What is List?
What is string and StringBuilder?
What is for loop?
What is foreach loop?
What is switch?
What is Method?
What is method overloading?
What is Constructor?
What is constructor overloading?
What is Boxing and Unboxing?
What is delegate in C# and uses of delegates?
What is Inheritance?
What are Value types and Reference types?
What is Exception Handling?
What is struct?
What is Dictionary?
What is Hashtable?
What is interface?
What is Abstraction?
What is Polymorphism?
What is Enums?
What is Sealed Class?
What is Partial Class?
Extension Methods?
What is static?
What is Encapsulation?
Difference between Equality Operator (==) and Equals() Method in C# ?
What is IEnumerable?
What is Serializing?
What is LINQ?
Differences between IEnumerable and IQueryable?
What is Multithreading?
What is File Handling?
What is late binding and early binding?
What is Singleton Design Patterns?
Encapsulation is the first principle of object-oriented programming. Encapsulation is a data hiding or process of binding data members (variables, methods, properties) into a single unit in a class. Encapsulation related the access modifier. Now given bellow the example code and explain the code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Reflection;
using testForClass1;
namespace testFor
{
public struct Student
{
//non-accebole variable
private int _id;
//accebole variable
public string _name;
public int Id { get { return this._id; } set { this._id = value; } }
public string Name { get { return this._name; } set { this._name = value; } }
public void PrintDetels()
{
Console.WriteLine("Student Id:"+_id+" "+"Student Name : "+_name);
}
}
public class Program
{
static void Main(string[] args)
{
//use struct object and proparty
Student std = new Student();
std.Id = 101;
std.Name = "Farhan";
std.PrintDetels();
//if name variable is public then we access it
std._name = "Sakib";
std.PrintDetels();
Console.Read();
}
}
}
In the code _id is private so it can’t direct access from another class. This variable access by the property but _name, it is possible to access by property or it possible to direct using the Student class object.